package com.zlj.request.encoding;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 全站编码问题，即把编码设置放到filter中解决乱码问题
 */
@WebServlet("/EncodingServlet")
public class EncodingServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		response.setContentType("text/html;charset=utf-8");   //设置响应编码
		String username = request.getParameter("username");   //获取参数
		response.getWriter().println(username);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		response.setContentType("text/html;charset=utf-8");   //设置响应编码
		String username = request.getParameter("username");   //获取参数
		response.getWriter().println(username);
	}
}
